//
//  StatusBottomView.swift
//  Weibo
//
//  Created by 周先生 on 15/11/15.
//  Copyright © 2015年 周先生. All rights reserved.
//

import UIKit
import SnapKit
class StatusBottomView: UIView {

    
    @objc private func retweetedBtnDidClick() {
    
        let temp = TempViewController()
        retweetedBtn.NavController()?.pushViewController(temp, animated: true)
    }
    //3,重写父类的构造方法 调用设置UI的方法
    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = UIColor(white: 0.98, alpha: 1)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //2,设置UI
    private func setupUI() {
    
        //添加子控件
        addSubview(retweetedBtn)
        addSubview(composeBtn)
        addSubview(likeBtn)

        //
        let w: CGFloat = 0.5
        let scale = 0.4
        //设置约束
        retweetedBtn.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(snp_top)
            make.left.equalTo(snp_left)
            make.height.equalTo(snp_height)
        }
        //分割线1
        let sepView1 = sepView()
        addSubview(sepView1)
        sepView1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedBtn.snp_right)
            make.height.equalTo(retweetedBtn.snp_height).multipliedBy(scale)
            make.centerY.equalTo(self.snp_centerY)
            make.width.equalTo(w)
        }
        
        composeBtn.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(snp_top)
            make.left.equalTo(retweetedBtn.snp_right)
            make.height.equalTo(snp_height)
            make.width.equalTo(retweetedBtn.snp_width)
        }
        //分割线2
        let sepView2 = sepView()
        addSubview(sepView2)
        sepView2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(composeBtn.snp_right)
            make.height.equalTo(retweetedBtn.snp_height).multipliedBy(scale)
            make.centerY.equalTo(self.snp_centerY)
            make.width.equalTo(w)
        }
        
        likeBtn.snp_makeConstraints { (make) -> Void in
            
            make.left.equalTo(composeBtn.snp_right)
            make.top.equalTo(snp_top)
            make.right.equalTo(snp_right)
            make.height.equalTo(snp_height)
            make.width.equalTo(retweetedBtn.snp_width)
        }
        /**
        添加点击事件
        */
        retweetedBtn.addTarget(self, action: "retweetedBtnDidClick", forControlEvents: .TouchUpInside)
    
    }
    //创建分割线
    private func sepView() -> UIView {
        let sepV = UIView()
        sepV.backgroundColor = UIColor.darkGrayColor()
        return sepV
        
    }

    //1,懒加载子控件
    private lazy var retweetedBtn: UIButton = UIButton(title: "转发", backImage: nil, color: UIColor.darkGrayColor(), image: "timeline_icon_retweet", size: 10)
    private lazy var composeBtn: UIButton = UIButton(title: "评论", backImage: nil, color: UIColor.darkGrayColor(), image: "timeline_icon_comment", size: 10)
    private lazy var likeBtn: UIButton = UIButton(title: "赞", backImage: nil, color: UIColor.darkGrayColor(), image: "timeline_icon_like", size: 10)
    }
